class Bullet extends egret.Bitmap {
	
	private static cacheDict:Object = {};
	public textureName : string;

	public constructor(textureName:string) {
		super(RES.getRes(textureName));
		this.textureName = textureName;
	}

	public static product(textureName:string):Bullet {
		if (Bullet.cacheDict[textureName] == null) {
			Bullet.cacheDict[textureName] = [];
		}
		var arr:Bullet[] = Bullet.cacheDict[textureName];
		var bullet:Bullet;
		if (arr.length > 0) {
			bullet = arr.pop();
		} else {
			bullet = new Bullet(textureName);
		}
		bullet.textureName = textureName;
		return bullet;
	}

	public static reclaim(bullet:Bullet) {
		if (Bullet.cacheDict[bullet.textureName] == null) {
			Bullet.cacheDict[bullet.textureName] = [];
		}
		var arr:Bullet[] = Bullet.cacheDict[bullet.textureName];
		if (arr.indexOf(bullet) == -1) {
			arr.push(bullet);
		}
	}

}